package com.mmm.nlp;

/**
 * Created with IntelliJ IDEA.
 * User: ChenZ
 * Date: 4/19/13
 * Time: 8:20 AM
 * To change this template use File | Settings | File Templates.
 */
public class Token
{
  private StringBuffer body;
  private String lexicon;
  private boolean isWord;

  public Token(String body, boolean isWord)
  {
    this.body = new StringBuffer(body);
    this.isWord = isWord;
  }

  public String getLexicon()
  {
    return lexicon;
  }

  public void setLexicon(String lexicon)
  {
    if (lexicon.length() > 0)
      this.lexicon = lexicon;
    else
      this.lexicon = null;
  }

  public String getBody()
  {
    return body.toString();
  }

  public void setBody(String body)
  {
    this.body = new StringBuffer(body);
  }

  public boolean isWord()
  {
    return isWord;
  }

  public void setWord(boolean word)
  {
    isWord = word;
  }

  public String toString()
  {
    return lexicon == null ? body.toString() : body.append('/').append(lexicon).toString();
  }
}
